package org.springframework.learn.beans.config;

import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.learn.beans.config.condition.LinuxCondition;
import org.springframework.learn.beans.config.condition.WindowsCondition;
import org.springframework.learn.beans.service.OrderService;

//@Conditional({WindowsCondition.class})
@Configuration
public class BeanConfig {

	/**
	 * 相当于xml配置文件中的factory-bean=beanConfig，factory-method=person1
	 * @return
	 */
    @Bean(name = "bill")
    public Person person1(){
        return new Person("Bill Gates",62);
    }

	/**
	 * 相当于xml配置文件中的class=org.springframework.learn.beans.config.BeanConfig，factory-method=person2
	 * @return
	 */
    @Bean("linus")
    public static Person person2(){
        return new Person("Linus",48);
    }

	/**
	 * NullBean的情况
	 * 在spring容器中存的是person3->NullBean
	 * @return
	 */
	@Primary
	@Bean
	public Person person3(){
		return new Person("person3",48);
	}

 }
